<?php
$table_string = "
addonarticle
,addonimages
,addoninfos
,addonshop
,addonsoft
,addonspec
,admin
,admintype
,advancedsearch
,arcatt
,arccache
,archives
,arcmulti
,arcrank
,arctiny
,arctype
,area
,channeltype
,co_htmls
,co_mediaurls
,co_note
,co_onepage
,co_urls
,diyforms
,dl_log
,downloads
,erradd
,feedback
,flink
,flinktype
,freelist
,homepageset
,keywords
,kwcache
,kwhash
,kwkeyword
,log
,member
,member_company
,member_feed
,member_flink
,member_friends
,member_group
,member_guestbook
,member_model
,member_msg
,member_operation
,member_person
,member_pms
,member_snsmsg
,member_space
,member_stow
,member_stowtype
,member_tj
,member_type
,member_vhistory
,moneycard_record
,moneycard_type
,mtypes
,multiserv_config
,myad
,myadtype
,mytag
,payment
,plugins_config
,plus
,purview
,pwd_tmp
,ratings
,scores
,search_cache
,search_keywords
,sgpage
,shops_delivery
,shops_orders
,shops_products
,shops_userinfo
,softconfig
,sphinx
,stepselect
,sysconfig
,sys_enum
,sys_module
,sys_set
,sys_task
,tagindex
,taglist
,uploads
,verifies
,vote
,vote_member";

$tables = explode(',',$table_string);
$originPrefix = 'dede_';
$seoPrefix = 'seo_';
$outFile = 'migrate_data.sql';

$queryTemplate = 'INSERT INTO `#seoTable#` SELECT * FROM `#originTable#`;';

$output = '';
foreach ($tables as $table) {
    $table = trim($table);
    $seoTable = $seoPrefix . $table;
    $originTable = $originPrefix . $table;
    $output .= str_replace(array('#seoTable#', '#originTable#'), array($seoTable, $originTable), $queryTemplate);
}

file_put_contents($outFile, $output);
